﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace BusinessModel
{
    /// <summary>
    /// * Unnormal Properties : ProductId, UnitId, SalePriceUnit, Product.
    /// </summary>
    public class BuyOrderDetail : BaseModel
    {
        #region Primitive Properties
        public Nullable<global::System.Int32> BuyOrderId
        {
            get
            {
                return _BuyOrderId;
            }
            set
            {
                if (_BuyOrderId != value)
                {
                    _BuyOrderId = value;
                    OnPropertyChanged("BuyOrderId");
                }
            }
        }
        private Nullable<global::System.Int32> _BuyOrderId;

        public Nullable<global::System.Int32> ProductId
        {
            get
            {
                return _ProductId;
            }
            set
            {
                if (_ProductId != value)
                {
                    _ProductId = value;
                    //if (value.HasValue)
                    //{
                    //    Product.Id = value.Value;
                    //}
                    OnPropertyChanged("ProductId");
                }
            }
        }
        private Nullable<global::System.Int32> _ProductId;

        public Nullable<global::System.Int32> UnitId
        {
            get
            {
                return _UnitId;
            }
            set
            {
                if (_UnitId != value)
                {
                    _UnitId = value;
                    OnPropertyChanged("UnitId");
                }
            }
        }
        private Nullable<global::System.Int32> _UnitId;

        public Nullable<global::System.Int32> SupplierId
        {
            get
            {
                return _SupplierId;
            }
            set
            {
                if (_SupplierId != value)
                {
                    _SupplierId = value;
                    OnPropertyChanged("SupplierId");
                }
            }
        }
        private Nullable<global::System.Int32> _SupplierId;

        public Nullable<global::System.Int32> DiscountTypeId
        {
            get
            {
                return _DiscountTypeId;
            }
            set
            {
                if (_DiscountTypeId != value)
                {
                    _DiscountTypeId = value;
                    OnPropertyChanged("DiscountTypeId");
                }
            }
        }
        private Nullable<global::System.Int32> _DiscountTypeId;

        public Nullable<global::System.Int32> DiscountValue
        {
            get
            {
                return _DiscountValue;
            }
            set
            {
                if (_DiscountValue != value)
                {
                    _DiscountValue = value;
                    OnPropertyChanged("DiscountValue");
                }
            }
        }
        private Nullable<global::System.Int32> _DiscountValue;

        public Nullable<global::System.Int32> Quantity
        {
            get
            {
                return _Quantity;
            }
            set
            {
                if (_Quantity != value)
                {
                    _Quantity = value;
                    OnPropertyChanged("Quantity");
                }
            }
        }
        private Nullable<global::System.Int32> _Quantity;

        public Nullable<global::System.Int32> BuyPriceUnit
        {
            get
            {
                return _BuyPriceUnit;
            }
            set
            {
                if (_BuyPriceUnit != value)
                {
                    _BuyPriceUnit = value;
                    OnPropertyChanged("BuyPriceUnit");
                }
            }
        }
        private Nullable<global::System.Int32> _BuyPriceUnit;

        public Nullable<global::System.Int32> SalePriceUnit
        {
            get
            {
                return _SalePriceUnit;
            }
            set
            {
                if (_SalePriceUnit != value)
                {
                    _SalePriceUnit = value;
                    //Product.SalePriceUnit = value;
                    //Product.UnitChanges.Where(p => p.Level == 0).Single().SalePriceUnit = value;
                    OnPropertyChanged("SalePriceUnit");
                }
            }
        }
        private Nullable<global::System.Int32> _SalePriceUnit;

        public Nullable<global::System.Boolean> IsConsign
        {
            get
            {
                return _IsConsign;
            }
            set
            {
                if (_IsConsign != value)
                {
                    _IsConsign = value;
                    OnPropertyChanged("IsConsign");
                }
            }
        }
        private Nullable<global::System.Boolean> _IsConsign;

        public Nullable<global::System.DateTime> BuyDate
        {
            get
            {
                return _BuyDate;
            }
            set
            {
                if (_BuyDate != value)
                {
                    _BuyDate = value;
                    OnPropertyChanged("BuyDate");
                }
            }
        }
        private Nullable<global::System.DateTime> _BuyDate;

        public global::System.String Note
        {
            get
            {
                return _Note;
            }
            set
            {
                if (_Note != value)
                {
                    _Note = value;
                    OnPropertyChanged("Note");
                }
            }
        }
        private global::System.String _Note;
        #endregion

        // Product.
        private Product _Product;
        public Product Product
        {
            get
            {
                if (_Product == null)
                    _Product = new Product();
                return _Product;
            }
            set 
            {
                if (_Product != value)
                {
                    _Product = value;
                    OnPropertyChanged("Product");
                }
            }
        }

        #region Extend Properties
        //UserName
        private string _UserName;
        public string UserName
        {
            get { return _UserName; }
            set
            {
                if (_UserName != value)
                {
                    _UserName = value;
                    OnPropertyChanged("UserName");
                }
            }
        }
        //TypeCode
        private string _TypeCode;
        public string TypeCode
        {
            get { return _TypeCode; }
            set
            {
                if (_TypeCode != value)
                {
                    _TypeCode = value;
                    OnPropertyChanged("TypeCode");
                }
            }
        }
        //Code
        private string _Code;
        public string Code
        {
            get { return _Code; }
            set
            {
                if (_Code != value)
                {
                    _Code = value;
                    OnPropertyChanged("Code");
                }
            }
        }
        //Name
        private string _Name;
        public string Name
        {
            get { return _Name; }
            set
            {
                if (_Name != value)
                {
                    _Name = value;
                    OnPropertyChanged("Name");
                }
            }
        }
        //ProductName
        private string _ProductName;
        public string ProductName
        {
            get { return _ProductName; }
            set
            {
                if (_ProductName != value)
                {
                    _ProductName = value;
                    OnPropertyChanged("ProductName");
                }
            }
        }
        //UnitName
        private string _UnitName;
        public string UnitName
        {
            get { return _UnitName; }
            set
            {
                if (_UnitName != value)
                {
                    _UnitName = value;
                    OnPropertyChanged("UnitName");
                }
            }
        }
        //SupplierName
        private string _SupplierName;
        public string SupplierName
        {
            get { return _SupplierName; }
            set
            {
                if (_SupplierName != value)
                {
                    _SupplierName = value;
                    OnPropertyChanged("SupplierName");
                }
            }
        }
        //DiscountTypeName
        private string _DiscountTypeName;
        public string DiscountTypeName
        {
            get { return _DiscountTypeName; }
            set
            {
                if (_DiscountTypeName != value)
                {
                    _DiscountTypeName = value;
                    OnPropertyChanged("DiscountTypeName");
                }
            }
        }
        // Total
        public Nullable<global::System.Int32> Total
        {
            get
            {
                return _Total;
            }
            set
            {
                if (_Total != value)
                {
                    _Total = value;
                    OnPropertyChanged("Total");
                }
            }
        }
        private Nullable<global::System.Int32> _Total;
        #endregion Extend Properties
    }
}
